/**
 * @(#)RetentLogConfigServiceImpl.java 2017年11月23日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.jsbd.boss.common.redis.RedisClient;
import org.jsbd.boss.dao.IRetentLogConfigDAO;
import org.jsbd.boss.domian.channel.RetentLogConfig;
import org.jsbd.boss.service.IRetentLogConfigService;
import org.jsbd.boss.util.CacheKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import edu.hziee.common.tcp.cache.CachedHolder;

/**
 * TODO 请加入本类的说明
 * 
 * @author <a href="mailto:xupengcheng@zhexinit.com" >徐鹏程</a>
 * @version 1.0.0
 */
@Service
public class RetentLogConfigServiceImpl implements IRetentLogConfigService {
	public static final Logger LOGGER = LoggerFactory.getLogger(RetentLogConfigServiceImpl.class);

	@Resource
	private IRetentLogConfigDAO retentLogConfigDAO;

	@Resource
	private RedisClient redisClient;

	@Resource
	private CachedHolder ehcache;

	@Override
	public List<RetentLogConfig> selectConfigList() {
		List<RetentLogConfig> configList = (List<RetentLogConfig>) ehcache.get(CacheKey.ALL_RETENT_FILL_CONFIG);
		if (configList == null) {
			configList = (List<RetentLogConfig>) redisClient.get(CacheKey.ALL_RETENT_FILL_CONFIG);
			if (configList != null) {
				ehcache.put(CacheKey.ALL_RETENT_FILL_CONFIG, configList);
			}
		}
		if (configList != null) {
			return configList;
		}
		configList = retentLogConfigDAO.selectAllList();
		redisClient.put(CacheKey.ALL_RETENT_FILL_CONFIG, configList, 300);
		return configList;
	}

	@Override
	public List<RetentLogConfig> selectConfigList(RetentLogConfig retentLogConfig) {
		return retentLogConfigDAO.selectList(retentLogConfig);
	}
}
